export const getUuid = () => {
  const s = []
  const hexDigits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  for (let i = 0; i < 32; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
  }
  s[14] = '4'
  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1)
  const uuid = s.join('')
  return uuid
}

export const cloneDeep = (target) => {
  let clone
  if (target == null || typeof target != 'object') return target
  clone = Object.assign({}, target)
  Object.keys(clone).forEach((key) => {
    clone[key] = typeof target[key] === 'object' ? cloneDeep(target[key]) : target[key]
  })
  if (Array.isArray(target)) {
    clone.length = target.length
    clone = Array.from(clone)
  }
  return clone
}
